<div id="test">
</div>
<div>
</div>
<div id="addDialog"></div>
<script>
	$(function(){
	$("#test").datagrid({
		title:'My DataGrid',
		url:'findAllUser.action',
		pagination:true,
		toolbar:[{
			id:'btnadd',
			text:'Add',
			iconCls:'icon-add',
			handler:function(){
				$('#addDialog').dialog({
					title:'add Information',
					buttons:[{text:'save',handler:function(){
						$("#addUserForm").submit();						
						$("#addDialog").dialog('close');																	
					}},
					{text:'close',handler:function(){
						$("#addDialog").dialog('close');
					}}],
					width:400,
					height:200,
					closed:false,
					cache:false,
					modal:true,
					href:'toAddUser.action'
				});
			}		
		}],
		columns:[[{field:'id',hidden:true},
		{field:'userName',title:'Name',styler:function(value,row,index){
			if(index<2){
				return 'background-color:#ffee00;color:red;';
			}
		}},
		{field:'userEmail',title:'Email'},
		{field:'opt',title:'Ofperation',width:100,align:'center', rowspan:2,
						formatter:function(value,row,index){
							return '<a href="#" onclick=\"deleteById('+row.id+')\">delete</a>';
						}
		
		}
		]
		],
		rownumbers:true,
	});
});
	function query(){
		alert("hello");
	}
	function deleteById(id){
		$.post("deleteUserById.action?user.id="+id,function(data){
			alert("delete "+data);
			$("#test").datagrid('reload');
		},"html");
	}
	
</script>